/**
 * 送货信息 - 编辑页面
 * @author miaoyl
 * @date 2018/01/09
 */
define(function () {

    var self,
        app = win.app,
        doc = document,
        vueData = {
            operation: '',
            form: {
                GWAK001: '',
                GWAKL003: '',
                GWAL021: '',
                GWAL020: '',
                GWAL018: '',
                GWAL003: ''
            },
            rules: {

            }
        },
        callObj,
        cb
    ;

    var Gwei025Edit = app.Module.extend({
        init: function () {
            self = this;
            self._super({
                _tag: 'gwei025_edit_gwal',
            }, win);
        },

        editData: function () {
            app.ajax({
                xurl: 'crm/gwei025/editGwal',
                xdata: vueData.form,
                loading: true,
                // okmsg: '送货信息修改成功',
                cb: function (result) {
                    if (result.ok) {
                        layer.close(layer.index);
                        if(vueData.operation == 'D'){
                            app.showSuccess("送货信息修改成功");
                        }else {
                            app.showSuccess("发票信息修改成功");
                        }
                        cb(vueData.form);
                    }
                }
            });
        },

        _call: function (obj) {
            cb = obj.cb;
            vueData.operation = obj.operation;
            app.extendUpLow({
                target: vueData.form,
                res: obj.data,
                reset: true
            });
        },
        _ready: function () {
            var vue = new Vue({
                el: '#gwei025_edit_gwal',
                data: vueData,
                methods: {
                    cancel: function () {
                        layer.close(layer.index);
                    },
                    saveData: function () {
                        this.$refs['form'].validate(function (valid) {
                            if (valid) {
                                self.editData();
                            }
                        });
                    }
                },
                watch: {},
                created: function () {
                    self._setEleIsReady('gwei025_edit_gwal');
                }
            });
        },

        _lazy: function () {
            this._super();
        }
    });

    return new Gwei025Edit();

});